package com.example.demo.service.aiService;

import com.example.demo.demo.invoke.DialogueState;
import com.example.demo.enums.ActionType;
import com.example.demo.enums.EmotionScene;
import org.springframework.stereotype.Service;

@Service
public class DialoguePolicyService {
    public ActionType decideNextAction(DialogueState state) {
        if (state.getUserGoal() == null || state.getUserGoal() == EmotionScene.UNKNOWN) {
            return ActionType.ASK_A_CLARIFYING_QUESTION;
        }

        switch (state.getUserGoal()) {
            case CONSIDERING_BREAKUP:
            case TRUST_ISSUES:
                boolean hasSeriousTopicInfo = state.isSlotFilled("EVENT") && (state.isSlotFilled("PERSON_CORE") || state.isSlotFilled("PERSON_RELATED"));
                return hasSeriousTopicInfo ? ActionType.PROVIDE_FINAL_ADVICE : ActionType.ASK_A_CLARIFYING_QUESTION;
            default:
                boolean hasDefaultInfo = state.isSlotFilled("EVENT") && state.isSlotFilled("PERSON_CORE");
                return hasDefaultInfo ? ActionType.PROVIDE_FINAL_ADVICE : ActionType.ASK_A_CLARIFYING_QUESTION;
        }
    }
}